#coding:utf-8
from model import WebSiteModel
import os

banner_list = [
            {'name': u'首页', 'url': '/'}, 
            {'name': u'博客', 'url': '/blog'},
            {'name': u'留言板', 'url': '/guestbook'},
        ]

#获取网站信息  
def get_webpage_strings(now=u'主页'):
    webpages = WebSiteModel.all().get()
    verpath = os.path.dirname('__filename__')
    verfile = open(verpath+'version.txt', 'r')
    ver = 'Ver ' + verfile.readline()
    if not webpages:
        webpage = WebSiteModel()
        webpage.save()
        webpage = {
            'title': u'SimpHome',
            'subtitle': u'A Simple Personal Homepage',
            'now': now,
            'home': '/',
            'timeoffset': 8,
            'numofentry': 10,
            'numofgreeting': 10,
            'numofcomment': 20,
            'orderofcomment': 0,
            'theme': 'default',
            'id': '',
            'key': '',
            'version': ver,
        }
    
    else:
        webpage = {
            'title': webpages.title,
            'subtitle': webpages.subtitle,
            'now': now,
            'home': webpages.home,  
            'timeoffset': webpages.timeoffset,
            'numofentry': webpages.numofentry,
            'numofgreeting': webpages.numofgreeting,
            'numofcomment': webpages.numofcomment,
            'orderofcomment': webpages.orderofcomment,
            'id': webpages.key().id(),
            'key': webpages.key(),
            'version': ver,
            'theme': webpages.theme,
            'owner': webpages.owner,
        }
    return webpage

